package com.hrzyit.whistle.comm.presenter

import com.hrzyit.base.ext.execute
import com.hrzyit.base.presenter.BasePresenter
import com.hrzyit.base.rx.BaseObserver
import com.hrzyit.whistle.comm.data.bean.DepartmentEntity
import com.hrzyit.whistle.comm.presenter.view.DepartmentView
import com.hrzyit.whistle.comm.service.IDepartmentService
import javax.inject.Inject

/**
 * 通讯录：单位相关 Presenter 逻辑
 * @author YangWei
 * @date 2019/3/24
 */
class DepartmentPresenter @Inject constructor() : BasePresenter<DepartmentView>() {

    @Inject
    lateinit var departmentService: IDepartmentService

    /**
     * 通讯录-单位列表
     */
    fun selectContactDeptList(userId:Long) {

        if (!checkNetWork()) {
            return
        }

        // 显示进度框
        mView.showLoading()

        departmentService.selectContactDeptList(userId)
            .execute(object : BaseObserver<MutableList<DepartmentEntity>>(mView) {
                override fun onNext(t: MutableList<DepartmentEntity>) {
                    mView.onGetSelectContactDeptListSuccess(t)
                }
            }, lifecycleProvider)
    }
}